#pragma once

#include <d3dx9.h>
#include "IScenery.h"
#include "IMovable.h"
#include "IRenderableObject.h"


struct IDirect3DDevice9;
class CViewFrustrum;
struct AABoundingBox;
class IMesh;

class CRenderableObject : public IMovable, public IRenderableObject
{
private:
   D3DXVECTOR3 m_rightVec;
   D3DXVECTOR3 m_upVec;
   D3DXVECTOR3 m_lookVec;
   D3DXVECTOR3 m_position;
   D3DXMATRIX m_mtxWorld;
   IMesh& m_mesh;
   D3DMATERIAL9 m_material;

   bool m_mtxWorldDirty;

public:
   CRenderableObject(IMesh& mesh, const D3DMATERIAL9& material);

   void render(CViewFrustrum& frustrum, IDirect3DDevice9& d3Device);

   AABoundingBox getWorldSpaceBoundingBox()const;

   void move(const D3DXVECTOR3& transVec);
   void rotate(float pitch, float yaw, float roll);

   const D3DXVECTOR3& getRightVec() const {return m_rightVec;}
   const D3DXVECTOR3& getUpVec() const {return m_upVec;}
   const D3DXVECTOR3& getLookVec() const {return m_lookVec;}
   const D3DXVECTOR3& getPosition() const {return m_position;}

   void setRightVec(const D3DXVECTOR3& vec) {m_rightVec = vec;}
   void setUpVec(const D3DXVECTOR3& vec) {m_upVec = vec;}
   void setLookVec(const D3DXVECTOR3& vec) {m_lookVec = vec;}

   bool is3D() const {return true;}

private:
   const D3DXMATRIX& getMtxWorld();
};

///////////////////////////////////////////////////////
